package com.ccom.core.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @Description
 * @Author zjj
 * @Date 2021/8/9
 */
@Getter
@AllArgsConstructor
public enum EnableEnum {
    /**
     * 可用
     */
    ENABLE(1, "yes"),
    /**
     * 不可用
     */
    DISABLE(0, "no");

    private Integer code;
    private String strCode;

    public static EnableEnum stateOf(Integer code) {
        for (EnableEnum state : values()) {
            if (state.getCode().equals(code)) {
                return state;
            }
        }
        return EnableEnum.DISABLE;
    }

    public static EnableEnum stateOf(String strCode) {
        for (EnableEnum state : values()) {
            if (state.getStrCode().equalsIgnoreCase(strCode)) {
                return state;
            }
        }
        return EnableEnum.DISABLE;
    }
}
